package com.niit.huodong1;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public class NIITEmployee implements Writable {

    private IntWritable id;
    private Text name;
    private IntWritable age;
    private Text phone;

    public NIITEmployee() {
        this.id = new IntWritable(0);
        this.name = new Text("");
        this.age = new IntWritable(0);
        this.phone = new Text("");
    }

    public NIITEmployee(int id, String name, int age, String phone) {
        this.id = new IntWritable(id);
        this.name = new Text(name);
        this.age = new IntWritable(age);
        this.phone = new Text(phone);
    }
    public void write (DataOutput out)throws IOException
    {
        this.id.write(out);
        this.name.write(out);
        this.age.write(out);
        this.phone.write(out);
    }
    public void readFields(DataInput in) throws IOException
    {
        this.id.readFields(in);
        this.name.readFields(in);
        this.age.readFields(in);
        this.phone.readFields(in);
    }

    @Override
    public String toString() {
        return "NIITEmployee{" +
                "id=" + id +
                ", name=" + name +
                ", age=" + age +
                ", phone=" + phone +
                '}';
    }
//    @Override
//    public String toString() {
//        return "NIITEmployee{" +
//                "id=" + id +
//                ", name=" + name +
//                ", age=" + age +
//                ", phone=" + phone +
//                '}';

    public IntWritable getId() {
        return id;
    }

    public void setId(IntWritable id) {
        this.id = id;
    }

    public Text getName() {
        return name;
    }

    public void setName(Text name) {
        this.name = name;
    }

    public IntWritable getAge() {
        return age;
    }

    public void setAge(IntWritable age) {
        this.age = age;
    }

    public Text getPhone() {
        return phone;
    }

    public void setPhone(Text phone) {
        this.phone = phone;
    }
}